package com.base.caselib.presenter;

import android.app.Activity;
import android.content.DialogInterface;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AlertDialog;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.arvin.imagepicker.Util;
import com.arvin.imagepicker.bean.ImageItem;
import com.arvin.imagepicker.widget.ImagePickView;
import com.base.caselib.R;
import com.base.caselib.bean.CaseAb;
import com.base.caselib.bean.CaseBean;
import com.base.caselib.bean.CaseDetailBean;
import com.base.caselib.bean.CaseSaveBean;
import com.base.caselib.bean.CaseType;
import com.base.caselib.bean.CheckBoxBean;
import com.base.caselib.bean.DropBean;
import com.base.caselib.bean.TaskInfo;
import com.base.caselib.bean.TempOraryBean;
import com.base.caselib.bean.UpateMainCaseInfoBean;
import com.base.caselib.bean.UpdateChildValueInfoBean;
import com.base.caselib.print.CasePrintUtil;
import com.base.caselib.utils.DownLoadUtils;
import com.base.caselib.utils.Utils;
import com.base.caselib.view.CaseView;
import com.base.caselib.widget.CheckBoxCustom;
import com.base.caselib.widget.DateCustom;
import com.base.caselib.widget.EditNumCustom;
import com.base.caselib.widget.EditTextCustom;
import com.base.caselib.widget.SingleCheckCustom;
import com.base.caselib.widget.SpinnerCustom;
import com.base.commonlib.base.BaseApp;
import com.base.commonlib.base.presenter.BasePresenter;
import com.base.commonlib.bean.EasyCaseModel;
import com.base.commonlib.http.RealNetWorkUtil;
import com.base.commonlib.http.utils.CallBackImpl;
import com.base.commonlib.utils.SystemUtil;
import com.base.commonlib.widget.SingleSearchDialog;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.reactivex.disposables.Disposable;

/**
 * Created by weikailiang on 2019/10/12.
 */

public class CasePresenter extends BasePresenter<CaseView> implements AMapLocationListener {
    public String ID = "ylp9W4bF9ykafcByq8R";
    public int isSimple = 2;
    private static final int ERROR_MESS = 1;
    private static final int SUCCESS_MESS = 2;
    public CaseBean mCaseBean = null;
    public String mTpeId = "";//案件类型ID
    public String mAnJianType = "";
    public String mNoticeId = "";
    private CaseSaveBean mCaseSaveBean = new CaseSaveBean();
    private CaseAb mCaseAb = new CaseAb();//案情摘要
    public String mCaseAbstract = "";
    private boolean isSave = true;//是否保存 （默认保存）
    private CaseDetailBean mDetailBean;
    private String cFormId="";

    public CaseBean.ModulesBean.RowsBean mPowerCoding;
    private List<UpdateChildValueInfoBean> mUpdateChildCaseInfoList = new ArrayList<>();

    private UpateMainCaseInfoBean mUpdateMainCaseInfo = new UpateMainCaseInfoBean();



    /**
     * 声明mlocationClient对象
     */
    private AMapLocationClient mLocationClient;
    /**
     * 声明mLocationOption对象
     */
    public AMapLocationClientOption mLocationOption = null;


    public CasePresenter(CaseView view, Activity activity) {
        super(view, activity);
    }

    private Handler mHandler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case ERROR_MESS:
                    mView.hidePb_mes();
                    mView.showMes("模块为找到索引");
                    break;
                case SUCCESS_MESS:

                    mView.hidePb_mes();
                    if (TextUtils.isEmpty(mTpeId)){
                        mView.showMes("请选择案件类型");
                        return;
                    }
                    if (isSave) {
                        if (mView.returnType().equals("1")||mView.returnType().equals("2")){
                            //保存
                            commitData();
                        }else if (mView.returnType().equals("3")||mView.returnType().equals("4")){
                            if (mView.returnType().equals("4")){
                                if (!TextUtils.isEmpty(mView.getCaseid())){
                                    getNotice();
                                }else{
                                    getNotice();
                                }
                            }else {
                                getNotice();
                            }
                        }else {
                            upSave();
                        }

                    }else {
                        //更新
                        updateMainValue();
                    }
                    break;
            }
        }
    };
    private void upSave(){
        mView.showPb();
        mCaseSaveBean.setMainDatas(mMasterCommBean);
        mCaseSaveBean.setSonDatas(mChildCommBean);
        CaseSaveBean.CommenBean mComBean = null;

        if (mView.returnType().equals("1")||mView.returnType().equals("2")){
            mComBean = new CaseSaveBean.CommenBean();
            mComBean.setFieldSave("case_number");
            mComBean.setValue(mAnJianType);
            mCaseSaveBean.getMainDatas().add(mComBean);

            mCaseAb.setCaseCame("巡查发现");
            mCaseAb.setCasePerson(mUser.getUserName()+"、"+mCurrentPartner.getUserName());

            mComBean = new CaseSaveBean.CommenBean();
            mComBean.setFieldSave("case_summary");
            mCaseAbstract = Utils.GetUpperdate(mCaseAb.getCaseTime())+",执法队员"+mCaseAb.getCasePerson()+"在"+mCaseAb.getCaseAddress()+mCaseAb.getCaseCame()+mCaseAb.getCaseName()+mCaseAb.getCaseLow()+"。";
            mComBean.setValue(mCaseAbstract);
            mCaseSaveBean.getMainDatas().add(mComBean);

            mCaseSaveBean.setFormMainValue(mCaseBean.getFormMainValue());
        }
        if (!mView.returnType().equals("5")&&!mView.returnType().equals("3")){
            mComBean = new CaseSaveBean.CommenBean();
            mComBean.setFieldSave("notification_number");
            mComBean.setValue(mNoticeId);
            mCaseSaveBean.getMainDatas().add(mComBean);
        }

        if (mView.returnType().equals("4")){
            mComBean = new CaseSaveBean.CommenBean();
            mComBean.setFieldSave("case_id");
            mComBean.setValue(mView.getCaseid());
            mCaseSaveBean.getMainDatas().add(mComBean);

        }
        if (mView.returnType().equals("3")){
            mComBean = new CaseSaveBean.CommenBean();
            mComBean.setFieldSave("notification_number");
            mComBean.setValue(mNoticeId);
            mCaseSaveBean.getMainDatas().add(mComBean);
        }
        for (CaseSaveBean.CommenBean bean: mCaseSaveBean.getMainDatas()){
            if (bean.getFieldSave().equals("create_user_id")){
                bean.setValue(mUser.getUserId());
            }
        }
        for (CaseSaveBean.CommenBean bean: mCaseSaveBean.getMainDatas()){
            if (bean.getFieldSave().equals("status")){
                bean.setValue("1");
            }
        }


        mCaseSaveBean.setFormId(mCaseBean.getId());

        mComBean = new CaseSaveBean.CommenBean();
        mComBean.setFieldSave("law_enforcing_department_name2");
        mComBean.setValue(mUser.getDeptId());
        mCaseSaveBean.getMainDatas().add(mComBean);

        mComBean = new CaseSaveBean.CommenBean();
        mComBean.setFieldSave("law_enforcing_member_name1");
        mComBean.setValue(mUser.getUserId());
        mCaseSaveBean.getMainDatas().add(mComBean);

        for (CaseSaveBean.CommenBean bean: mCaseSaveBean.getMainDatas()){
            if (bean.getFieldSave().equals("law_enforcing_member_name2")){
                bean.setValue(mCurrentPartner.getId());
            }
        }

        mComBean = new CaseSaveBean.CommenBean();
        mComBean.setFieldSave("law_enforcing_department_name");
        mComBean.setValue(mUser.getCompanyId());
        mCaseSaveBean.getMainDatas().add(mComBean);

        boolean flag = false;
        for (CaseSaveBean.CommenBean b : mCaseSaveBean.getMainDatas()){
            if (b.getFieldSave().equals("unlawful_act")){
                if (TextUtils.isEmpty(b.getValue())){
                    mView.hidePb();
                    mView.showMes("请选择违法行为");
                    return;
                }
            }
            if (b.getFieldSave().equals("applicable_case")){
                if (TextUtils.isEmpty(b.getValue())){
                    mView.hidePb();
                    mView.showMes("请选择适用案由");
                    return;
                }else {
                    flag = true;
                }
            }
        }
        if (flag){
            //请求权利编码
            boolean lag = false;
            for (CaseSaveBean.CommenBean b : mCaseSaveBean.getMainDatas()){
                if (b.getFieldSave().equals("case_cause_number")){
                    lag = true;
                }
            }
            if (lag){
                if (mPowerCoding!=null){
                    Map<String,String> parmes = new HashMap<>();
                    parmes.put("dropValue",mPowerCoding.getSelectFieldValue());
                    parmes.put("dropLabel",mPowerCoding.getSelectFieldLabel());
                    parmes.put("dropTable",mPowerCoding.getSelectTableValue());
                    parmes.put("dropConditionFormula",mPowerCoding.getDropFunction());
                    List<DropBean> list = new Gson().fromJson(mPowerCoding.getDropJsonArr(),new TypeToken<List<DropBean>>(){}.getType());
                    for (DropBean dropBean : list){
                        if (dropBean.getRank().equals("02200002")){
                            for (CaseSaveBean.CommenBean b : mCaseSaveBean.getMainDatas()){
                                if (b.getFieldSave().equals("unlawful_act")){
                                    dropBean.setValue(b.getValue());
                                }
                            }
                        }
                    }
                    parmes.put("dropConditionFormula",mPowerCoding.getDropFunction());
                    parmes.put("dropConditionJson",new Gson().toJson(list));
                    Disposable disposable = RealNetWorkUtil.postContent()
                            .method("api-customerform/baseForm/dropValue")
                            .content(parmes)
                            .build().enqueueForArray(CheckBoxBean.class, new CallBackImpl<List<CheckBoxBean>>() {
                                @Override
                                public void onError(int code, String msg, String errMsg) {
                                    mView.hidePb();
//                                    mView.showMes("权力编码未获取到");
                                    commitSaveData();
                                }

                                @Override
                                public void onNext(List<CheckBoxBean> objects) {
                                    mView.hidePb();
                                    if (objects.size()==0){
//                                        mView.showMes("权力编码未获取到");
                                        commitSaveData();
                                    }else {
                                        for (CaseSaveBean.CommenBean b : mCaseSaveBean.getMainDatas()){
                                            if (b.getFieldSave().equals("case_cause_number")){
                                                b.setValue(objects.get(0).getDropLabel());
                                            }
                                        }
                                        commitSaveData();
                                    }
                                }
                            });
                    mCompositeDisposable.add(disposable);

                }else {
                    mView.hidePb();
                    commitSaveData();
                }
            }else {
                mView.hidePb();
                commitSaveData();
            }
        }else {
            mView.hidePb();
            commitSaveData();
        }


    }

    public void commitSaveData(){
        //初始化控件
        mView.showPb_mes("正在提交数据");
        Disposable disposable = RealNetWorkUtil.postContent()
                .method("api-customerform//baseFunction/save2")
                .content(mCaseSaveBean)
                .build().enqueue(CaseDetailBean.class, new CallBackImpl<CaseDetailBean>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(CaseDetailBean objects) {
                        mView.hidePb_mes();
                        mDetailBean = objects;
                        mView.saveSuccess(objects.getId());

                    }
                });
        mCompositeDisposable.add(disposable);
    }
    private void commitData(){
        getCaseNum(isSimple,mTpeId);
    }
    @Override
    public void start() {
        super.start();

        //初始化控件
        mView.showPb_mes("正在渲染界面");
        Disposable disposable = RealNetWorkUtil.get()
                .method("api-customerform/baseFunction/goToAdd?cformId="+ID)
                .params(new HashMap<String, Object>())
                .build().enqueue(CaseBean.class, new CallBackImpl<CaseBean>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                         mView.hidePb_mes();
                        if (!TextUtils.isEmpty(msg)) {
                            mView.showMes(msg);
                        }

                    }
                    @Override
                    public void onNext(CaseBean version) {
                        mView.hidePb_mes();
                        cFormId = version.getId();
                        mView.returnCaseBean(version);
                    }
                });
        mCompositeDisposable.add(disposable);
    }

    //获取联动数据
    public void getFieldValue(Map<String,String> map, final SpinnerCustom custom, final boolean isDefault){
        //初始化控件
        mView.showPb_mes("正在请求数据");
        Disposable disposable = RealNetWorkUtil.postContent()
                .method("api-customerform/baseForm/dropValue")
                .content(map)
                .build().enqueueForArray(CheckBoxBean.class, new CallBackImpl<List<CheckBoxBean>>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(List<CheckBoxBean> objects) {
                        mView.hidePb_mes();
                        if (objects.size()==0){
                           if (!isDefault){
                               mView.showMes("无数据");
                           }
                        }else {
                            if (isDefault){
                                if (objects.size()>0) {
                                    custom.setData(objects);
                                    if (custom.getFileSave().equals("law_enforcing_department_name")){//执法部门
                                        for (CheckBoxBean bean : objects){
                                            if (bean.getDropLabel().equals(mUser.getCompanyName())){
                                                custom.setDefault(bean);
                                            }
                                        }
                                    }else {
                                        custom.setDefault(objects.get(0));
                                    }
                                }
                            }else {
                                custom.setData(objects);
                                custom.show(false);
                            }
                        }
                    }
                });
        mCompositeDisposable.add(disposable);
    }

    public void setmCaseBean(CaseBean bean){
        this.mCaseBean = bean;
    }

    List<CaseSaveBean.CommenBeanToUp> list = null;

    //新增保存案件
    public void save(List<LinearLayout> linearLayouts){
        isSave = true;
        if (mCaseBean == null){
            mView.showMes("请先渲染页面");
            return;
        }
        mCaseSaveBean.setFormId(mCaseBean.getId());
        mCaseSaveBean.setFormMainValue(mCaseBean.getFormMainValue());
        mChildCommBean.clear();
        mMasterCommBean.clear();
        mView.showPb_mes("正在构建实体");
        //遍历主表拼接字段
        if (mCaseBean != null){
            structure(linearLayouts);
        }else {
            mView.showMes("请先渲染页面");
        }


    }
    //构建主表实体/构建字表实体
    private void structure(final List<LinearLayout> linearLayouts){
        //开启线程构建实体
        new Thread(new Runnable() {
            @Override
            public void run() {
                //需要在子线程中处理的逻辑
                for (LinearLayout layout : linearLayouts){
                    if (layout.getTag() != null){
                        for (CaseBean.ModulesBean modulesBean : mCaseBean.getModules()){
                            String type = modulesBean.getModuleIndex()+"";
                            if (type.equals(layout.getTag().toString())){
                                //找到当前控件实体
                                if (modulesBean.getModuleType() ==1){//主表
                                    saveDate(layout,modulesBean,true,null);
                                }else if (modulesBean.getModuleType() ==2){//字表
                                    List<List<CaseSaveBean.CommenBeanToUp>> mCommBeanUp = new ArrayList<>();
                                    List<CaseSaveBean.CommenBeanToUp> list = new ArrayList<>();
                                    saveDate(layout,modulesBean,false,list);
                                    if (list != null&&list.size()>0){
                                        if (mChildCommBean.containsKey(modulesBean.getChildName())){
                                            for (Map.Entry<String, List<List<CaseSaveBean.CommenBeanToUp>>> entry : mChildCommBean.entrySet()) {
                                                if (entry.getKey().equals(modulesBean.getChildName())){
                                                    mCommBeanUp.addAll(entry.getValue());
                                                }
                                            }
                                            String fileSave = "";
                                            List<CaseSaveBean.CommenBeanToUp> ups = new ArrayList<>();
                                            for (CaseSaveBean.CommenBeanToUp commenBeanToUp : list){
                                                if (commenBeanToUp.getFieldSave().equals(fileSave)){
                                                    List<CaseSaveBean.CommenBeanToUp> list1 = new ArrayList<>();
                                                    list1.add(commenBeanToUp);
                                                    mCommBeanUp.add(list1);
                                                    mChildCommBean.put(modulesBean.getChildName(),mCommBeanUp);
                                                }else {
                                                    ups.add(commenBeanToUp);
                                                }
                                                fileSave = commenBeanToUp.getFieldSave();
                                            }
                                            mCommBeanUp.add(ups);
                                            mChildCommBean.remove(modulesBean.getChildName());
                                            mChildCommBean.put(modulesBean.getChildName(),mCommBeanUp);
                                        }else {
                                            String fileSave = "";
                                            List<CaseSaveBean.CommenBeanToUp> ups = new ArrayList<>();
                                            for (CaseSaveBean.CommenBeanToUp commenBeanToUp : list){
                                                if (commenBeanToUp.getFieldSave().equals(fileSave)){
                                                    List<CaseSaveBean.CommenBeanToUp> list1 = new ArrayList<>();
                                                    for (CaseSaveBean.CommenBeanToUp com : list){
                                                        if (!com.getFieldSave().equals(commenBeanToUp.getFieldSave())){
                                                            list1.add(com);
                                                        }
                                                    }
                                                    list1.add(commenBeanToUp);
                                                    mCommBeanUp.add(list1);
                                                }else {
                                                    ups.add(commenBeanToUp);
                                                }
                                                fileSave = commenBeanToUp.getFieldSave();
                                            }
                                            mCommBeanUp.add(ups);
                                            mChildCommBean.put(modulesBean.getChildName(),mCommBeanUp);
                                        }
                                    }

                                }
                            }
                        }
                    }else {
                        mHandler.sendEmptyMessage(ERROR_MESS);
                        return;
                    }
                }
                mHandler.sendEmptyMessage(SUCCESS_MESS);
            }
        }).start();
    }



    private Map<String,List<List<CaseSaveBean.CommenBeanToUp>>> mChildCommBean = new HashMap<>();
    List<CaseSaveBean.CommenBean> mMasterCommBean = new ArrayList<>();
    private void saveDate(LinearLayout views,CaseBean.ModulesBean bean,boolean isMarstr,List<CaseSaveBean.CommenBeanToUp> list){
        CaseSaveBean.CommenBean commenBean = null;
        CaseSaveBean.CommenBeanToUp commenBeanUp = null;
            List<View> childsViews = getAllChildViews(views);
            for (View view : childsViews){
                if (view instanceof EditTextCustom) {
                    if (isMarstr){
                        EditTextCustom custom = (EditTextCustom) view;
                        if(!TextUtils.isEmpty(custom.getmEtText())){
                            BaseApp.setHistoryText(mUser.getUserId(),custom.getmEtText());
                        }
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                    //主表
                                    commenBean = new CaseSaveBean.CommenBean();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (TextUtils.isEmpty(custom.getmEtText())){
                                        if (rowsBean.getDefaultValue().equals("021900001")){
                                            commenBean.setValue(rowsBean.getFixValue());
                                        }else if (rowsBean.getDefaultValue().equals("021900003")){

                                            switch (rowsBean.getLoginValue()){
                                                case "userId":
                                                    commenBean.setValue(mUser.getUserId());
                                                    break;
                                                case "account":
                                                    commenBean.setValue(mUser.getUserName());
                                                    break;
                                                case "accountId":
                                                    commenBean.setValue(mUser.getUserId());
                                                    break;
                                                case "realName":
                                                    commenBean.setValue(mUser.getUserName());
                                                    break;
                                                case "organizeId":
                                                    commenBean.setValue(mUser.getCompanyId());
                                                    break;
                                                case "organizeName":
                                                    commenBean.setValue(mUser.getCompanyName());
                                                    break;
                                                case "departmentId":
                                                    commenBean.setValue(mUser.getDeptId());
                                                    break;
                                                case "departmentName":
                                                    commenBean.setValue(mUser.getDeptName());
                                                    break;
                                                case "positionId":
                                                    commenBean.setValue(mUser.getDeptId());
                                                    break;
                                                case "positionName":
                                                    commenBean.setValue(mUser.getDeptName());
                                                    break;
                                            }
                                        }
                                    }else {
                                        commenBean.setValue(TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                    }
                                }else {
                                    commenBean.setValue(TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                }
                                if (rowsBean.getFieldSave().equals("notification_number")){
                                    mNoticeId = (TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                }
                                if (rowsBean.getFieldSave().equals("occurred_address")){
                                    mCaseAb.setCaseAddress(TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                }
                                if (rowsBean.getFieldSave().contains("litigant_org_lr_name")||rowsBean.getFieldSave().equals("litigant_citizen_name")){
                                    if (TextUtils.isEmpty(custom.getmEtText())){

                                    }else {
                                        mCaseAb.setCaseName(TextUtils.isEmpty(custom.getmEtText()) ? null : custom.getmEtText());
                                    }
                                }
                                    commenBean.setConType(rowsBean.getConType());
                                    commenBean.setFieldSave(rowsBean.getFieldSave());
                                    commenBean.setValidate(rowsBean.getValidate());
                                    commenBean.setRowLabel(rowsBean.getRowLabel());

                                    mMasterCommBean.add(commenBean);
                            }
                        }
                    }else {
                        EditTextCustom custom = (EditTextCustom) view;
                        if(!TextUtils.isEmpty(custom.getmEtText())){
                            BaseApp.setHistoryText(mUser.getUserId(),custom.getmEtText());
                        }
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                    //子表
                                    commenBeanUp = new CaseSaveBean.CommenBeanToUp();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (TextUtils.isEmpty(custom.getmEtText())){
                                        if (rowsBean.getDefaultValue().equals("021900001")){
                                            commenBeanUp.setValue(rowsBean.getFixValue());
                                        }else if (rowsBean.getDefaultValue().equals("021900003")){

                                            switch (rowsBean.getLoginValue()){
                                                case "userId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "account":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "accountId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "realName":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "organizeId":
                                                    commenBeanUp.setValue(mUser.getCompanyId());
                                                    break;
                                                case "organizeName":
                                                    commenBeanUp.setValue(mUser.getCompanyName());
                                                    break;
                                                case "departmentId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "departmentName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                                case "positionId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "positionName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                            }
                                        }
                                    }else {
                                        commenBeanUp.setValue(TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                    }
                                }else {
                                    commenBeanUp.setValue(TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                }
                                if (rowsBean.getFieldSave().equals("notification_number")){
                                    mNoticeId = (TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                }
                                if (rowsBean.getFieldSave().equals("occurred_address")){//案发地点
                                    mCaseAb.setCaseAddress(TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                }
                                if (rowsBean.getFieldSave().contains("litigant_org_lr_name")||rowsBean.getFieldSave().equals("litigant_citizen_name")){//当事人
                                    if (TextUtils.isEmpty(custom.getmEtText())){

                                    }else {
                                        mCaseAb.setCaseName(TextUtils.isEmpty(custom.getmEtText()) ? null : custom.getmEtText());
                                    }
                                }
                                    commenBeanUp.setConType(rowsBean.getConType());
                                    commenBeanUp.setFieldSave(rowsBean.getFieldSave());
                                    childPutBean(bean.getChildName(),commenBeanUp,list);
                                }
                        }
                    }

                }else if (view instanceof EditNumCustom){
                    if (isMarstr){
                        EditNumCustom custom = (EditNumCustom) view;
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                    //主表
                                    commenBean = new CaseSaveBean.CommenBean();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (TextUtils.isEmpty(custom.getmEtText())){
                                        if (rowsBean.getDefaultValue().equals("021900001")){
                                            commenBean.setValue(rowsBean.getFixValue());
                                        }else if (rowsBean.getDefaultValue().equals("021900003")){


                                            switch (rowsBean.getLoginValue()){
                                                case "userId":
                                                    commenBean.setValue(mUser.getUserId());
                                                    break;
                                                case "account":
                                                    commenBean.setValue(mUser.getUserName());
                                                    break;
                                                case "accountId":
                                                    commenBean.setValue(mUser.getUserId());
                                                    break;
                                                case "realName":
                                                    commenBean.setValue(mUser.getUserName());
                                                    break;
                                                case "organizeId":
                                                    commenBean.setValue(mUser.getCompanyId());
                                                    break;
                                                case "organizeName":
                                                    commenBean.setValue(mUser.getCompanyName());
                                                    break;
                                                case "departmentId":
                                                    commenBean.setValue(mUser.getDeptId());
                                                    break;
                                                case "departmentName":
                                                    commenBean.setValue(mUser.getDeptName());
                                                    break;
                                                case "positionId":
                                                    commenBean.setValue(mUser.getDeptId());
                                                    break;
                                                case "positionName":
                                                    commenBean.setValue(mUser.getDeptName());
                                                    break;
                                            }
                                        }
                                    }else {
                                        commenBean.setValue(TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                    }
                                }else {
                                    commenBean.setValue(TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                }
                                    commenBean.setConType(rowsBean.getConType());
                                    commenBean.setFieldSave(rowsBean.getFieldSave());
                                    commenBean.setValidate(rowsBean.getValidate());
                                    commenBean.setRowLabel(rowsBean.getRowLabel());
                                    mMasterCommBean.add(commenBean);
                            }
                        }
                    }else {
                        EditNumCustom custom = (EditNumCustom) view;
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                    //子表
                                commenBeanUp = new CaseSaveBean.CommenBeanToUp();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (TextUtils.isEmpty(custom.getmEtText())){
                                        if (rowsBean.getDefaultValue().equals("021900001")){
                                            commenBeanUp.setValue(rowsBean.getFixValue());
                                        }else if (rowsBean.getDefaultValue().equals("021900003")){

                                            switch (rowsBean.getLoginValue()){
                                                case "userId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "account":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "accountId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "realName":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "organizeId":
                                                    commenBeanUp.setValue(mUser.getCompanyId());
                                                    break;
                                                case "organizeName":
                                                    commenBeanUp.setValue(mUser.getCompanyName());
                                                    break;
                                                case "departmentId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "departmentName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                                case "positionId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "positionName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                            }
                                        }
                                    }else {
                                        commenBeanUp.setValue(TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                    }
                                }else {
                                    commenBeanUp.setValue(TextUtils.isEmpty(custom.getmEtText())?null:custom.getmEtText());
                                }
                                commenBeanUp.setConType(rowsBean.getConType());
                                commenBeanUp.setFieldSave(rowsBean.getFieldSave());
                                    childPutBean(bean.getChildName(),commenBeanUp,list);
                                }
                        }
                    }

                }else if (view instanceof DateCustom){
                    if (isMarstr){
                        DateCustom custom = (DateCustom) view;
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                    //主表
                                    commenBean = new CaseSaveBean.CommenBean();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (TextUtils.isEmpty(custom.getmTvDate())){
                                        if (rowsBean.getDefaultValue().equals("021900001")){
                                            commenBean.setValue(rowsBean.getFixValue());
                                        }else if (rowsBean.getDefaultValue().equals("021900003")){


                                            switch (rowsBean.getLoginValue()){
                                                case "userId":
                                                    commenBean.setValue(mUser.getUserId());
                                                    break;
                                                case "account":
                                                    commenBean.setValue(mUser.getUserName());
                                                    break;
                                                case "accountId":
                                                    commenBean.setValue(mUser.getUserId());
                                                    break;
                                                case "realName":
                                                    commenBean.setValue(mUser.getUserName());
                                                    break;
                                                case "organizeId":
                                                    commenBean.setValue(mUser.getCompanyId());
                                                    break;
                                                case "organizeName":
                                                    commenBean.setValue(mUser.getCompanyName());
                                                    break;
                                                case "departmentId":
                                                    commenBean.setValue(mUser.getDeptId());
                                                    break;
                                                case "departmentName":
                                                    commenBean.setValue(mUser.getDeptName());
                                                    break;
                                                case "positionId":
                                                    commenBean.setValue(mUser.getDeptId());
                                                    break;
                                                case "positionName":
                                                    commenBean.setValue(mUser.getDeptName());
                                                    break;
                                            }
                                        }
                                    }else {

                                        commenBean.setValue(TextUtils.isEmpty(custom.getmTvDate())?null:custom.getmTvDate());
                                    }
                                }else {
                                    commenBean.setValue(TextUtils.isEmpty(custom.getmTvDate())?null:custom.getmTvDate());
                                }
                                if (rowsBean.getFieldSave().equals("occurred_time")){//案发时间
                                    mCaseAb.setCaseTime(TextUtils.isEmpty(custom.getmTvDate())?null:custom.getmTvDate());
                                }
                                    commenBean.setConType(rowsBean.getConType());
                                    commenBean.setFieldSave(rowsBean.getFieldSave());
                                    commenBean.setValidate(rowsBean.getValidate());
                                    commenBean.setRowLabel(rowsBean.getRowLabel());
                                    commenBean.setValue(TextUtils.isEmpty(custom.getmTvDate())?null:custom.getmTvDate());
                                    mMasterCommBean.add(commenBean);
                            }
                        }
                    }else {
                        DateCustom custom = (DateCustom) view;
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                    //子表
                                commenBeanUp = new CaseSaveBean.CommenBeanToUp();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (TextUtils.isEmpty(custom.getmTvDate())){
                                        if (rowsBean.getDefaultValue().equals("021900001")){
                                            commenBeanUp.setValue(rowsBean.getFixValue());
                                        }else if (rowsBean.getDefaultValue().equals("021900003")){


                                            switch (rowsBean.getLoginValue()){
                                                case "userId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "account":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "accountId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "realName":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "organizeId":
                                                    commenBeanUp.setValue(mUser.getCompanyId());
                                                    break;
                                                case "organizeName":
                                                    commenBeanUp.setValue(mUser.getCompanyName());
                                                    break;
                                                case "departmentId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "departmentName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                                case "positionId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "positionName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                            }
                                        }
                                    }else {
                                        commenBeanUp.setValue(TextUtils.isEmpty(custom.getmTvDate())?null:custom.getmTvDate());
                                    }
                                }else {
                                    commenBeanUp.setValue(TextUtils.isEmpty(custom.getmTvDate())?null:custom.getmTvDate());
                                }
                                if (rowsBean.getFieldSave().equals("occurred_time")){//案发时间
                                    mCaseAb.setCaseTime(TextUtils.isEmpty(custom.getmTvDate())?null:custom.getmTvDate());
                                }
                                commenBeanUp.setConType(rowsBean.getConType());
                                commenBeanUp.setFieldSave(rowsBean.getFieldSave());
                                    childPutBean(bean.getChildName(),commenBeanUp,list);
                            }
                        }
                    }

                }else if (view instanceof SpinnerCustom){
                    if (isMarstr){
                        SpinnerCustom custom = (SpinnerCustom) view;
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){

                                if (rowsBean.getFieldSave().equals("law_type")||rowsBean.getFieldSave().equals("case_type")){
                                    mTpeId = custom.getmCurrentBoxBean()==null?null:custom.getmCurrentBoxBean().getDropValue();
                                }
                                    //主表
                                    commenBean = new CaseSaveBean.CommenBean();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (TextUtils.isEmpty(custom.getmCurrentBoxBean().getDropValue())){
                                        if (rowsBean.getDefaultValue().equals("021900001")){
                                            if (rowsBean.getFixValue()!=null) {
                                                commenBean.setValue(rowsBean.getFixValue());
                                            }
                                        }else if (rowsBean.getDefaultValue().equals("021900003")){

                                            switch (rowsBean.getLoginValue()){
                                                case "userId":
                                                    commenBean.setValue(mUser.getUserId());
                                                    break;
                                                case "account":
                                                    commenBean.setValue(mUser.getUserName());
                                                    break;
                                                case "accountId":
                                                    commenBean.setValue(mUser.getUserId());
                                                    break;
                                                case "realName":
                                                    commenBean.setValue(mUser.getUserName());
                                                    break;
                                                case "organizeId":
                                                    commenBean.setValue(mUser.getCompanyId());
                                                    break;
                                                case "organizeName":
                                                    commenBean.setValue(mUser.getCompanyName());
                                                    break;
                                                case "departmentId":
                                                    commenBean.setValue(mUser.getDeptId());
                                                    break;
                                                case "departmentName":
                                                    commenBean.setValue(mUser.getDeptName());
                                                    break;
                                                case "positionId":
                                                    commenBean.setValue(mUser.getDeptId());
                                                    break;
                                                case "positionName":
                                                    commenBean.setValue(mUser.getDeptName());
                                                    break;
                                            }
                                        }
                                    }else {
                                        commenBean.setValue(custom.getmCurrentBoxBean()==null?null:custom.getmCurrentBoxBean().getDropValue());
                                    }
                                }else {
                                    commenBean.setValue(custom.getmCurrentBoxBean()==null?null:custom.getmCurrentBoxBean().getDropValue());
                                }
                                if (rowsBean.getFieldSave().equals("unlawful_act")){//违法行为
                                    mCaseAb.setCaseLow(custom.getmCurrentBoxBean()==null?null:custom.getmCurrentBoxBean().getDropLabel());
                                }
                                    commenBean.setConType(rowsBean.getConType());
                                    commenBean.setFieldSave(rowsBean.getFieldSave());
                                    commenBean.setValidate(rowsBean.getValidate());
                                    commenBean.setRowLabel(rowsBean.getRowLabel());

                                    mMasterCommBean.add(commenBean);
                            }
                        }
                    }else {
                        SpinnerCustom custom = (SpinnerCustom) view;
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                    //子表
                                commenBeanUp = new CaseSaveBean.CommenBeanToUp();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (TextUtils.isEmpty(custom.getmCurrentBoxBean().getDropValue())){
                                        if (rowsBean.getDefaultValue().equals("021900001")){
                                            commenBeanUp.setValue(rowsBean.getFixValue());
                                        }else if (rowsBean.getDefaultValue().equals("021900003")){


                                            switch (rowsBean.getLoginValue()){
                                                case "userId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "account":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "accountId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "realName":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "organizeId":
                                                    commenBeanUp.setValue(mUser.getCompanyId());
                                                    break;
                                                case "organizeName":
                                                    commenBeanUp.setValue(mUser.getCompanyName());
                                                    break;
                                                case "departmentId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "departmentName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                                case "positionId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "positionName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                            }
                                        }
                                    }else {
                                        commenBeanUp.setValue(custom.getmCurrentBoxBean()==null?null:custom.getmCurrentBoxBean().getDropValue());
                                    }
                                }else {
                                    commenBeanUp.setValue(custom.getmCurrentBoxBean()==null?null:custom.getmCurrentBoxBean().getDropValue());
                                }
                                commenBeanUp.setConType(rowsBean.getConType());
                                commenBeanUp.setFieldSave(rowsBean.getFieldSave());
                                    childPutBean(bean.getChildName(),commenBeanUp,list);
                                }
                        }
                    }

                }else if (view instanceof SingleCheckCustom){
                    if (isMarstr){
                        SingleCheckCustom custom = (SingleCheckCustom) view;
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                    //主表
                                    commenBean = new CaseSaveBean.CommenBean();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (custom.getmCurrentBoxBean() != null){
                                        if (custom.getmCurrentBoxBean().getDropValue() != null && TextUtils.isEmpty(custom.getmCurrentBoxBean().getDropValue())){
                                            if (rowsBean.getDefaultValue().equals("021900001")){
                                                commenBean.setValue(rowsBean.getFixValue());
                                            }else if (rowsBean.getDefaultValue().equals("021900003")){


                                                switch (rowsBean.getLoginValue()){
                                                    case "userId":
                                                        commenBean.setValue(mUser.getUserId());
                                                        break;
                                                    case "account":
                                                        commenBean.setValue(mUser.getUserName());
                                                        break;
                                                    case "accountId":
                                                        commenBean.setValue(mUser.getUserId());
                                                        break;
                                                    case "realName":
                                                        commenBean.setValue(mUser.getUserName());
                                                        break;
                                                    case "organizeId":
                                                        commenBean.setValue(mUser.getCompanyId());
                                                        break;
                                                    case "organizeName":
                                                        commenBean.setValue(mUser.getCompanyName());
                                                        break;
                                                    case "departmentId":
                                                        commenBean.setValue(mUser.getDeptId());
                                                        break;
                                                    case "departmentName":
                                                        commenBean.setValue(mUser.getDeptName());
                                                        break;
                                                    case "positionId":
                                                        commenBean.setValue(mUser.getDeptId());
                                                        break;
                                                    case "positionName":
                                                        commenBean.setValue(mUser.getDeptName());
                                                        break;
                                                }
                                            }
                                        }else {
                                            commenBean.setValue(custom.getmCurrentBoxBean()==null?null:custom.getmCurrentBoxBean().getDropValue());
                                        }
                                    }

                                }else {
                                    commenBean.setValue(custom.getmCurrentBoxBean()==null?null:custom.getmCurrentBoxBean().getDropValue());
                                }
                                    commenBean.setConType(rowsBean.getConType());
                                    commenBean.setFieldSave(rowsBean.getFieldSave());
                                    commenBean.setValidate(rowsBean.getValidate());
                                    commenBean.setRowLabel(rowsBean.getRowLabel());

                                    mMasterCommBean.add(commenBean);
                            }
                        }
                    }else {
                        SingleCheckCustom custom = (SingleCheckCustom) view;
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                    //子表
                                commenBeanUp = new CaseSaveBean.CommenBeanToUp();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (TextUtils.isEmpty(custom.getmCurrentBoxBean().getDropValue())){
                                        if (rowsBean.getDefaultValue().equals("021900001")){
                                            commenBeanUp.setValue(rowsBean.getFixValue());
                                        }else if (rowsBean.getDefaultValue().equals("021900003")){


                                            switch (rowsBean.getLoginValue()){
                                                case "userId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "account":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "accountId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "realName":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "organizeId":
                                                    commenBeanUp.setValue(mUser.getCompanyId());
                                                    break;
                                                case "organizeName":
                                                    commenBeanUp.setValue(mUser.getCompanyName());
                                                    break;
                                                case "departmentId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "departmentName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                                case "positionId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "positionName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                            }
                                        }
                                    }else {
                                        commenBeanUp.setValue(custom.getmCurrentBoxBean()==null?null:custom.getmCurrentBoxBean().getDropValue());
                                    }
                                }else {
                                    commenBeanUp.setValue(custom.getmCurrentBoxBean()==null?null:custom.getmCurrentBoxBean().getDropValue());
                                }
                                commenBeanUp.setConType(rowsBean.getConType());
                                commenBeanUp.setFieldSave(rowsBean.getFieldSave());
                                    childPutBean(bean.getChildName(),commenBeanUp,list);
                            }
                        }
                    }

                }else if (view instanceof CheckBoxCustom){
                    if (isMarstr){
                        CheckBoxCustom custom = (CheckBoxCustom) view;
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                    //主表
                                    commenBean = new CaseSaveBean.CommenBean();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (TextUtils.isEmpty(custom.getmCurrentValue())){
                                        if (rowsBean.getDefaultValue().equals("021900001")){
                                            commenBean.setValue(rowsBean.getFixValue());
                                        }else if (rowsBean.getDefaultValue().equals("021900003")){


                                            switch (rowsBean.getLoginValue()){
                                                case "userId":
                                                    commenBean.setValue(mUser.getUserId());
                                                    break;
                                                case "account":
                                                    commenBean.setValue(mUser.getUserName());
                                                    break;
                                                case "accountId":
                                                    commenBean.setValue(mUser.getUserId());
                                                    break;
                                                case "realName":
                                                    commenBean.setValue(mUser.getUserName());
                                                    break;
                                                case "organizeId":
                                                    commenBean.setValue(mUser.getCompanyId());
                                                    break;
                                                case "organizeName":
                                                    commenBean.setValue(mUser.getCompanyName());
                                                    break;
                                                case "departmentId":
                                                    commenBean.setValue(mUser.getDeptId());
                                                    break;
                                                case "departmentName":
                                                    commenBean.setValue(mUser.getDeptName());
                                                    break;
                                                case "positionId":
                                                    commenBean.setValue(mUser.getDeptId());
                                                    break;
                                                case "positionName":
                                                    commenBean.setValue(mUser.getDeptName());
                                                    break;
                                            }
                                        }
                                    }else {
                                        commenBean.setValue(custom.getmCurrentValue());
                                    }
                                }else {
                                    commenBean.setValue(custom.getmCurrentValue());
                                }
                                    commenBean.setConType(rowsBean.getConType());
                                    commenBean.setFieldSave(rowsBean.getFieldSave());
                                    commenBean.setValidate(rowsBean.getValidate());
                                    commenBean.setRowLabel(rowsBean.getRowLabel());
                                    mMasterCommBean.add(commenBean);
                            }
                        }
                    }else {
                        CheckBoxCustom custom = (CheckBoxCustom) view;
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                    //子表
                                commenBeanUp = new CaseSaveBean.CommenBeanToUp();
                                if (rowsBean.getIsDefault()==1)
                                {
                                    if (TextUtils.isEmpty(custom.getmCurrentValue())){
                                        if (rowsBean.getDefaultValue().equals("021900001")){
                                            commenBeanUp.setValue(rowsBean.getFixValue());
                                        }else if (rowsBean.getDefaultValue().equals("021900003")){


                                            switch (rowsBean.getLoginValue()){
                                                case "userId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "account":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "accountId":
                                                    commenBeanUp.setValue(mUser.getUserId());
                                                    break;
                                                case "realName":
                                                    commenBeanUp.setValue(mUser.getUserName());
                                                    break;
                                                case "organizeId":
                                                    commenBeanUp.setValue(mUser.getCompanyId());
                                                    break;
                                                case "organizeName":
                                                    commenBeanUp.setValue(mUser.getCompanyName());
                                                    break;
                                                case "departmentId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "departmentName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                                case "positionId":
                                                    commenBeanUp.setValue(mUser.getDeptId());
                                                    break;
                                                case "positionName":
                                                    commenBeanUp.setValue(mUser.getDeptName());
                                                    break;
                                            }
                                        }
                                    }else {
                                        commenBeanUp.setValue(custom.getmCurrentValue());
                                    }
                                }else {
                                    commenBeanUp.setValue(custom.getmCurrentValue());
                                }
                                commenBeanUp.setConType(rowsBean.getConType());
                                commenBeanUp.setFieldSave(rowsBean.getFieldSave());
                                childPutBean(bean.getChildName(),commenBeanUp,list);
                            }
                        }
                    }


                }else if (view instanceof ImagePickView){
                    if (!isMarstr){
                        ImagePickView custom = (ImagePickView) view;
                        for (CaseBean.ModulesBean.RowsBean rowsBean : bean.getRows()) {
                            String index = rowsBean.getRowIndex()+"";
                            if (custom.getmRowIndex().equals(index)){
                                List<ImageItem> items = custom.getPics();
                                if (items.size()==0)return;
                                //子表
                               for (ImageItem item: items){
                                   if (item.path ==null)continue;
                                   //多张图片上传
                                   commenBeanUp = new CaseSaveBean.CommenBeanToUp();
                                   if (rowsBean.getIsDefault()==1)
                                   {
                                       if (custom.getPics()!=null){
                                           if (rowsBean.getDefaultValue().equals("021900001")){
                                               commenBeanUp.setValue(rowsBean.getFixValue());
                                           }else if (rowsBean.getDefaultValue().equals("021900003")){

                                               switch (rowsBean.getLoginValue()){
                                                   case "userId":
                                                       commenBeanUp.setValue(mUser.getUserId());
                                                       break;
                                                   case "account":
                                                       commenBeanUp.setValue(mUser.getUserName());
                                                       break;
                                                   case "accountId":
                                                       commenBeanUp.setValue(mUser.getUserId());
                                                       break;
                                                   case "realName":
                                                       commenBeanUp.setValue(mUser.getUserName());
                                                       break;
                                                   case "organizeId":
                                                       commenBeanUp.setValue(mUser.getCompanyId());
                                                       break;
                                                   case "organizeName":
                                                       commenBeanUp.setValue(mUser.getCompanyName());
                                                       break;
                                                   case "departmentId":
                                                       commenBeanUp.setValue(mUser.getDeptId());
                                                       break;
                                                   case "departmentName":
                                                       commenBeanUp.setValue(mUser.getDeptName());
                                                       break;
                                                   case "positionId":
                                                       commenBeanUp.setValue(mUser.getDeptId());
                                                       break;
                                                   case "positionName":
                                                       commenBeanUp.setValue(mUser.getDeptName());
                                                       break;
                                               }
                                           }
                                       }else {
                                           CaseSaveBean.FileInfo info = new CaseSaveBean.FileInfo();
                                           info.setName(item.name);
                                           info.setFileType(item.name.substring(item.name.length()-3,item.name.length()));
                                           info.setContent(Util.path2String(item.path));
                                           commenBeanUp.setValue(new Gson().toJson(info));
                                       }
                                   }else {
                                       CaseSaveBean.FileInfo info = new CaseSaveBean.FileInfo();
                                       info.setName(item.name);
                                       info.setFileType(item.name.substring(item.name.length()-3,item.name.length()));
                                       info.setContent(Util.path2String(item.path));
                                       commenBeanUp.setValue(new Gson().toJson(info));
                                   }
                                   commenBeanUp.setConType(rowsBean.getConType());
                                   commenBeanUp.setFieldSave(rowsBean.getFieldSave());

                                   childPutBean(bean.getChildName(),commenBeanUp,list);
                               }
                            }
                        }
                    }
                }
            }

    }

    private void childPutBean(String field,CaseSaveBean.CommenBeanToUp bean,List<CaseSaveBean.CommenBeanToUp> mList){
        if (TextUtils.isEmpty(bean.getValue())){
            bean.setValue("");
        }
        if (bean.getFieldSave().equals("gatherer")){
            bean.setValue(mUser.getUserId());
        }
        mList.add(bean);
    }


    private List<View> getAllChildViews(View view) {
        List<View> allchildren = new ArrayList<View>();
        if (view instanceof ViewGroup) {
            ViewGroup vp = (ViewGroup) view;
            for (int i = 0; i < vp.getChildCount(); i++) {
                View viewchild = vp.getChildAt(i);
                allchildren.add(viewchild);
                //再次 调用本身（递归）
                allchildren.addAll(getAllChildViews(viewchild));
            }
        }
        return allchildren;
    }


    public void getInfoByProType(){
        if (mDetailBean == null){
            mView.showMes("请重新进入界面");
            return;
        }
        List<Map<String,String>> mList = new ArrayList<>();
        Map<String,String> mPreType = new HashMap<>();
        for (CaseDetailBean.ModulesBean bean : mDetailBean.getModules()){
                for (CaseBean.ModulesBean.RowsBean mRow : bean.getRows()){
                    if (mRow.getIsProField()==1){
                        mPreType.put(mRow.getFieldSave(),mRow.getValue());
                    }
                }
        }
        mList.add(mPreType);
        mView.showPb();
        Map<String,Object> params = new HashMap<>();
        params.put("preRole",mList);
        params.put("preType",mCaseBean.getId());
        Disposable disposable = RealNetWorkUtil.postContent()
                .method("api-process/lPred/getInfoByPreType")
                .content(params)
                .build().enqueueForArray(CaseType.class, new CallBackImpl<List<CaseType>>() {

                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(List<CaseType> caseTypes) {
                        mView.hidePb();
                        if (caseTypes!=null&&caseTypes.size()>0){
                            mView.returnCaseTypeList(caseTypes);
                        }else {
//                            mView.showMes("未查到流程");
                        }
                    }
                });
        mCompositeDisposable.add(disposable);
    }

    public void getNotice(){
        mView.showPb();
        Map<String,Object> params = new HashMap<>();
        if (mView.returnType().equals("4")){//先行登记
            params.put("ruleId","EBGF0omuEef0gf7Rxrg");
            params.put("caseType",mTpeId);
        }else if (mView.returnType().equals("3"))//暂扣物品
        {
            params.put("ruleId", "EBGF0omuEef0gf7Rxrg");
            params.put("caseType",mTpeId);
        }else {//一般案件
            if (RealNetWorkUtil.TYPE.equals("0")){//吴中综合执法
                params.put("ruleId", "W1CYcYKaiXYrwszWyCB");
                params.put("caseType",mTpeId);
            }else if (RealNetWorkUtil.TYPE.equals("1")){//昆山综合执法
                params.put("ruleId", "HaZB5mZslEj5OiODAGC");
                params.put("caseType",mTpeId);
            }else {
                //其他
                params.put("ruleId", "HaZB5mZslEj5OiODAGC");
                params.put("caseType",mTpeId);
            }

            params.put("type","AJ");
        }
        Disposable disposable = RealNetWorkUtil.postContent()
                .method("api-code/code")
                .content(params)
                .build().enqueue(String.class, new CallBackImpl<String>() {

                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(String caseTypes) {
                        mView.hidePb();
                        mNoticeId = caseTypes;
                        mView.returnNotice(caseTypes);
                        upSave();
                    }
                });
        mCompositeDisposable.add(disposable);
    }
    public void getCaseNum(final int isSimple, String typeId){
        mView.showPb();
        Map<String,Object> params = new HashMap<>();
        if (RealNetWorkUtil.TYPE.equals("1")){
            if (isSimple==1){
                params.put("ruleId","aXA5TBEW64uoBRy1lR");
            }else {
                params.put("ruleId","GO4biaKcCkvjSHbIhtm");
            }
        }else if (RealNetWorkUtil.TYPE.equals("0")){
            params.put("ruleId", "BXA5TBEW64uoBRy1lRl");
        }
        params.put("simple",isSimple==2?"":"简");
        params.put("caseType",typeId);
        Disposable disposable = RealNetWorkUtil.postContent()
                .method("api-code/code")
                .content(params)
                .build().enqueue(String.class, new CallBackImpl<String>() {

                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(String caseTypes) {
                        mView.hidePb();
                        mAnJianType = caseTypes;
                        if (isSimple==2) {
                            if (mView.returnType().equals("1")){
                                if (TextUtils.isEmpty(mNoticeId)){
                                    getNotice();
                                }else {
                                    upSave();
                                }
                            }else {
                                getNotice();
                            }
                        }else if (isSimple ==1){
                            upSave();
                        }else {
                            getNotice();
                        }
                    }

                });
        mCompositeDisposable.add(disposable);
    }

    //控制显示隐藏清空数据
    public void showHindViewClearData(View view){
        if (view instanceof EditTextCustom){
            EditTextCustom custom = (EditTextCustom) view;
            custom.setmEtText("");
        }else if (view instanceof EditNumCustom){
            EditNumCustom custom = (EditNumCustom) view;
            custom.setmEtText("");
        }else if (view instanceof DateCustom){
            DateCustom custom = (DateCustom) view;
            custom.setmTvDate("");
        }else if (view instanceof SpinnerCustom){
            SpinnerCustom custom = (SpinnerCustom) view;
            custom.setDefault(new CheckBoxBean());
        }else if (view instanceof SingleCheckCustom){
            SingleCheckCustom custom = (SingleCheckCustom) view;
            custom.setDefault("");
        }else if (view instanceof CheckBoxCustom){
            CheckBoxCustom custom = (CheckBoxCustom) view;
        }else if (view instanceof ImagePickView){
            ImagePickView custom = (ImagePickView) view;
            custom.setPics(new ArrayList<ImageItem>());
        }
    }
    //更新案件
    public void updataCase(List<LinearLayout> linearLayouts){
        isSave = false;
        if (mCaseBean == null){
            mView.showMes("请先渲染页面");
            return;
        }
        mCaseSaveBean.setFormId(mCaseBean.getId());
        mCaseSaveBean.setFormMainValue(mCaseBean.getFormMainValue());
        mChildCommBean.clear();
        mMasterCommBean.clear();
        mView.showPb_mes("正在构建实体");
        //遍历主表拼接字段
        if (mCaseBean != null){
            structure(linearLayouts);
        }else {
            mView.showMes("请先渲染页面");
        }
    }
    private void updateMainValue(){
        mView.showPb();
        mUpdateMainCaseInfo.setMainDatas(mMasterCommBean);
        CaseSaveBean.CommenBean mComBean = new CaseSaveBean.CommenBean();
        mComBean.setFieldSave("case_number");
        mComBean.setValue(mAnJianType);
        mUpdateMainCaseInfo.getMainDatas().add(mComBean);
        mComBean = new CaseSaveBean.CommenBean();
        mComBean.setFieldSave("notification_number");
        mComBean.setValue(mNoticeId);
        mUpdateMainCaseInfo.getMainDatas().add(mComBean);

        mComBean = new CaseSaveBean.CommenBean();
        mComBean.setFieldSave("case_summary");
        mCaseAb.setCaseCame("巡查发现");
        mCaseAb.setCasePerson(mUser.getUserName()+"、"+mCurrentPartner.getUserName());
        mCaseAbstract = Utils.GetUpperdate(mCaseAb.getCaseTime())+",执法队员"+mCaseAb.getCasePerson()+"在"+mCaseAb.getCaseAddress()+mCaseAb.getCaseCame()+mCaseAb.getCaseName()+mCaseAb.getCaseLow()+"。";
        mComBean.setValue(mCaseAbstract);
        mUpdateMainCaseInfo.getMainDatas().add(mComBean);
        mUpdateMainCaseInfo.setFormId(mCaseBean.getId());
        mUpdateMainCaseInfo.setFormMainValue(mCaseBean.getFormMainValue());

        mComBean = new CaseSaveBean.CommenBean();
        mComBean.setFieldSave("law_enforcing_department_name2");
        mComBean.setValue(mUser.getDeptId());
        mUpdateMainCaseInfo.getMainDatas().add(mComBean);

        mComBean = new CaseSaveBean.CommenBean();
        mComBean.setFieldSave("law_enforcing_member_name1");
        mComBean.setValue(mUser.getUserId());
        mUpdateMainCaseInfo.getMainDatas().add(mComBean);

        for (CaseSaveBean.CommenBean bean: mUpdateMainCaseInfo.getMainDatas()){
            if (bean.getFieldSave().equals("create_user_id")){
                bean.setValue(mUser.getUserId());
            }
        }

        for (CaseSaveBean.CommenBean bean: mUpdateMainCaseInfo.getMainDatas()){
            if (bean.getFieldSave().equals("law_enforcing_member_name2")){
                bean.setValue(mCurrentPartner.getId());
            }
        }


        mComBean = new CaseSaveBean.CommenBean();
        mComBean.setFieldSave("law_enforcing_department_name");
        mComBean.setValue(mUser.getCompanyId());
        mUpdateMainCaseInfo.getMainDatas().add(mComBean);
        mUpdateMainCaseInfo.setId(mView.getCaseid());

        boolean flag = false;
        for (CaseSaveBean.CommenBean b : mUpdateMainCaseInfo.getMainDatas()){
            if (b.getFieldSave().equals("unlawful_act")){
                if (TextUtils.isEmpty(b.getValue())){
                    mView.hidePb();
                    mView.showMes("请选择违法行为");
                    return;
                }
            }
            if (b.getFieldSave().equals("applicable_case")){
                if (TextUtils.isEmpty(b.getValue())){
                    mView.hidePb();
                    mView.showMes("请选择适用案由");
                    return;
                }else {
                    flag = true;
                }
            }
        }
        if (flag){
            //请求权利编码
            boolean lag = false;
            for (CaseSaveBean.CommenBean b : mUpdateMainCaseInfo.getMainDatas()){
                if (b.getFieldSave().equals("case_cause_number")){
                    lag = true;
                }
            }
            if (lag){
                if (mPowerCoding!=null){
                    Map<String,String> parmes = new HashMap<>();
                    parmes.put("dropValue",mPowerCoding.getSelectFieldValue());
                    parmes.put("dropLabel",mPowerCoding.getSelectFieldLabel());
                    parmes.put("dropTable",mPowerCoding.getSelectTableValue());
                    parmes.put("dropConditionFormula",mPowerCoding.getDropFunction());
                    List<DropBean> list = new Gson().fromJson(mPowerCoding.getDropJsonArr(),new TypeToken<List<DropBean>>(){}.getType());
                    for (DropBean dropBean : list){
                        if (dropBean.getRank().equals("02200002")){
                            for (CaseSaveBean.CommenBean b : mUpdateMainCaseInfo.getMainDatas()){
                                if (b.getFieldSave().equals("applicable_case")){
                                    dropBean.setValue(b.getValue());
                                }
                            }
                        }
                    }
                    parmes.put("dropConditionFormula",mPowerCoding.getDropFunction());
                    parmes.put("dropConditionJson",new Gson().toJson(list));
                    Disposable disposable = RealNetWorkUtil.postContent()
                            .method("api-customerform/baseForm/dropValue")
                            .content(parmes)
                            .build().enqueueForArray(CheckBoxBean.class, new CallBackImpl<List<CheckBoxBean>>() {
                                @Override
                                public void onError(int code, String msg, String errMsg) {
                                    mView.hidePb();
//                                    mView.showMes("权力编码未获取到");
                                    upcommitData();
                                }

                                @Override
                                public void onNext(List<CheckBoxBean> objects) {
                                    mView.hidePb();
                                    if (objects.size()==0){
//                                        mView.showMes("权力编码未获取到");
                                        upcommitData();
                                    }else {
                                        for (CaseSaveBean.CommenBean b : mUpdateMainCaseInfo.getMainDatas()){
                                            if (b.getFieldSave().equals("case_cause_number")){
                                                b.setValue(objects.get(0).getDropLabel());
                                            }
                                        }
                                        upcommitData();
                                    }
                                }
                            });
                    mCompositeDisposable.add(disposable);

                }else {
                    upcommitData();
                }
            }else {
                upcommitData();
            }
        }else {
            upcommitData();
        }

    }
    private void upcommitData(){
        //初始化控件
        mView.showPb_mes("正在提交数据");
        Disposable disposable = RealNetWorkUtil.postContent()
                .method("api-customerform/baseFunction/update1")
                .content(mUpdateMainCaseInfo)
                .build().enqueue(String.class, new CallBackImpl<String>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        mView.showMes("保存失败");
                    }

                    @Override
                    public void onNext(String objects) {
                        mView.hidePb_mes();
                        updateChildValue();
                    }
                });
        mCompositeDisposable.add(disposable);
    }
    int i = 0;

    private void updateChildValue(){
        mUpdateChildCaseInfoList.clear();
        UpdateChildValueInfoBean mUpdateChildCaseInfo = null;

        i = 0;
        for (Map.Entry<String, List<List<CaseSaveBean.CommenBeanToUp>>> entry : mChildCommBean.entrySet()) {
            i++;
            String mapKey = entry.getKey();

            if (mDetailBean != null){
                for (CaseDetailBean.ModulesBean modulesBean : mDetailBean.getModules()){
                    if (mapKey.equals(modulesBean.getChildName())){
                        for (CaseDetailBean.ModulesBean.ChildValuesBean valuesBean : modulesBean.getChildValues()){
                            mUpdateChildCaseInfo = new UpdateChildValueInfoBean();
                            mUpdateChildCaseInfo.setSonTable(mapKey);
                            List<CaseSaveBean.CommenBeanToUp> list = new ArrayList<>();
                            mUpdateChildCaseInfo.setSonDatas(list);
                            for (List<CaseSaveBean.CommenBeanToUp> beanToUps : entry.getValue()){
                                for (CaseSaveBean.CommenBeanToUp be : beanToUps){
                                    if (be.getFieldSave().equals("gatherer")){
                                        be.setValue(mUser.getUserId());
                                    }
                                }
                                mUpdateChildCaseInfo.getSonDatas().addAll(beanToUps);
                            }
                            mUpdateChildCaseInfo.setMainId(mView.getCaseid());

                            mUpdateChildCaseInfo.setId(valuesBean.getChild_id());
                            mUpdateChildCaseInfoList.add(mUpdateChildCaseInfo);
                        }
                    }
                }
            }

            commitChildValue(mUpdateChildCaseInfoList);
        }
    }

    private void commitChildValue(List<UpdateChildValueInfoBean> upBean){
        final int count = mChildCommBean.size();
        //初始化控件
        mView.showPb_mes("正在提交数据");
        Disposable disposable = RealNetWorkUtil.postContent()
                .method("api-customerform/baseFunction/viceUpdateBatch")
                .content(upBean)
                .build().enqueue(String.class, new CallBackImpl<String>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        mView.showMes("保存失败");
                    }

                    @Override
                    public void onNext(String objects) {
                        mView.hidePb_mes();
                        if (count == i) {
                            mView.showMes("更新成功");
                        }else {
                            mView.showMes("更新第"+i+"个字表成功");
                        }
                    }
                });
        mCompositeDisposable.add(disposable);
    }


    public void startLocationForLl(){
        mLocationClient = new AMapLocationClient(mActivity);
        mLocationOption = new AMapLocationClientOption();
        mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
        mLocationOption.setOnceLocation(true);
        mLocationOption.setOnceLocationLatest(true);
        mLocationOption.setHttpTimeOut(8000);
        mLocationOption.setNeedAddress(true);
        mLocationOption.setLocationCacheEnable(true);
        // 设置定位监听
        mLocationClient.setLocationListener(this);
        // 设置定位参数
        mLocationClient.setLocationOption(mLocationOption);
        startMapLocation();
    }
    /**
     * 开启定位
     */
    public void startMapLocation() {
        //判断是否开启了，没有开启就开启
        if (!mLocationClient.isStarted()) {
            mLocationClient.startLocation();
        }
    }

    /**
     * 停止定位服务
     */
    public void stopMapLocation() {
        //判断服务是否开启了，若开启了则停止
        if (mLocationClient.isStarted()) {
            mLocationClient.stopLocation();
        }
    }

    @Override
    public void onLocationChanged(AMapLocation aMapLocation) {
        if (aMapLocation != null) {
            if (aMapLocation.getErrorCode() == 0) {
                // 可在其中解析amapLocation获取相应内容。
                //给接口设置数据
                if (TextUtils.isEmpty(aMapLocation.getAddress())||aMapLocation.getAddress() == null){
                    return;
                }
                mView.returnLocation(aMapLocation);
                stopMapLocation();
            } else {
                mView.showMes("定位权限未开启");
                //定位失败时，可通过ErrCode（错误码）信息来确定失败的原因，errInfo是错误信息，详见错误码表。
                Log.e("AmapError", "location Error, ErrCode:"
                        + aMapLocation.getErrorCode() + ", errInfo:"
                        + aMapLocation.getErrorInfo());
                stopMapLocation();
            }
        } else {
            stopMapLocation();
        }
    }


    public void getPdfUrlAddress(String mCaseId, final String name){
        //初始化图片
        mView.showPb_mes("正在请求地址");
        Map<String,Object> params = new HashMap<>();
        params.put("dataId",mCaseId);
        params.put("funcId","xianchangjiancha");
        params.put("modelId","YPijz0ywa52U8vNioma");

        Disposable disposable = RealNetWorkUtil.get()
                .method("api-model/preservationEvidence")
                .params(params)
                .build().enqueue(String.class, new CallBackImpl<String>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(String objects) {
                        mView.hidePb_mes();
                        downLoadFiel(RealNetWorkUtil.getBaseUrl()+"api-file"+objects,name);
                    }
                });
        mCompositeDisposable.add(disposable);
    }
    public void getPdfUrlEaseCase(String mCaseId, final String name){
        //初始化图片
        mView.showPb_mes("正在请求地址");
        Map<String,Object> params = new HashMap<>();
        params.put("dataId",mCaseId);
        params.put("funcId","xianchangjiancha");
        params.put("modelId","wsmb_0001");

        Disposable disposable = RealNetWorkUtil.get()
                .method("api-model/wordworkaz4")
                .params(params)
                .build().enqueue(String.class, new CallBackImpl<String>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(String objects) {
                        mView.hidePb_mes();
                        downLoadFiel(RealNetWorkUtil.getBaseUrl()+"api-file"+objects,name);
                    }
                });
        mCompositeDisposable.add(disposable);
    }

    DownLoadUtils downLoadUtils;
    public void downLoadFiel(String url,String name){
        String[] names = url.split("\\.");
        String fileName = name+"."+names[names.length-1];

        File file = new File(SystemUtil.getAppDir());
        if (!file.exists()){
            file.mkdirs();
        }
        File file1 = new File(SystemUtil.getAppDir()+fileName);
        if (file1.exists()){
            file1.delete();
        }
        TaskInfo info = new TaskInfo();
        info.setName(fileName);
        info.setPath(SystemUtil.getAppDir());
        info.setUrl(url);
        downLoadUtils = new DownLoadUtils(mActivity,info);
        downLoadUtils.showDownDialog();
    }


    @Override
    public void release() {
        super.release();
        if (mHandler != null){
            mHandler.removeCallbacksAndMessages(null);
        }
        if (mLocationClient != null) {
            mLocationClient.stopLocation();
            mLocationClient.onDestroy();
        }
        if (downLoadUtils != null){
            downLoadUtils.onDestory();
        }
    }


    /**
     * 申请预审
     * @param preId 预定义流程id
     * @param billId 案件id
     * @param funcId  表单id
     * @param tbFlag  自定义表单表名
     * @param content  表单标题
     * @param nextCaseStatus 下个案件状态
     */
    public void BindCase(String preId,String billId,String funcId,String tbFlag,String content,String nextCaseStatus){
        mView.showPb_mes("正在提交数据");
        Map<String,Object> params = new HashMap<>();
        params.put("preId",preId);
        params.put("billId",billId);
        params.put("funcId",funcId);
        params.put("tbFlag",tbFlag);
        params.put("content",content);
        params.put("nextCaseStatus",nextCaseStatus);
        params.put("status","2");
        params.put("isSendSMS",RealNetWorkUtil.TYPE.equals("0")?1:0);
        params.put("appContent","符合受理条件，建议受理。");
        params.put("todoSource","02300003");
        params.put("modelId","y7RgLtwaDqfpJr0j1gD");
        Disposable disposable = RealNetWorkUtil.postContent()
                .method("api-process/lApp/addOwn")
                .content(params)
                .build().enqueue(String.class, new CallBackImpl<String>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(String objects) {
                        mView.hidePb_mes();
                        mView.showMes(objects);
                        mView.returnApplySuccess();
                    }
                });
        mCompositeDisposable.add(disposable);
    }

    public void getPrintEaseCase(String caseId){
        mView.showPb();
        Disposable disposable = RealNetWorkUtil.get()
                .method("api-case/punishCase/getEasyCae")
                .addParams("caseId",caseId)
                .build().enqueue(EasyCaseModel.class, new CallBackImpl<EasyCaseModel>() {

                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(EasyCaseModel model) {
                        mView.hidePb();
                        model.setParentName(mUser.getUserName()+","+mCurrentPartner.getUserName());
                        CasePrintUtil.printEasyCase(mActivity,model);
                    }

                });
        mCompositeDisposable.add(disposable);
    }

    //转入案件
    public void changeInto(){
        List<CheckBoxBean> list = new ArrayList<>();
        CheckBoxBean bean = null;
        bean = new CheckBoxBean();
        bean.setDropLabel("简易案件");
        bean.setDropValue("0");
        list.add(bean);
        bean.setDropLabel("一般案件");
        bean.setDropValue("1");
        list.add(bean);
        bean.setDropLabel("重大案件");
        bean.setDropValue("2");
        list.add(bean);
        SingleSearchDialog<CheckBoxBean> dialog = new SingleSearchDialog<CheckBoxBean>(mActivity, "请选择", list, new SingleSearchDialog.OnItemChooseListener() {
            @Override
            public void onItemChoose(Object o) {
                CheckBoxBean bean = (CheckBoxBean) o;
                showContent(bean.getDropValue());
            }
        });
        dialog.show();
    }
    private void showContent(final String turnType){
        AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
        View view = LayoutInflater.from(mActivity).inflate(R.layout.dialog_comm_up, null);
        final EditText et = view.findViewById(R.id.app_content);
        builder.setView(view);
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
               if (TextUtils.isEmpty(et.getText().toString())){
                   mView.showMes("请输入审批内容");
                   return;
               }
                commitChangeInfo(et.getText().toString(),turnType);
            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        builder.create().show();
    }

    private void commitChangeInfo(String appContent,String turnType){
        mView.showPb_mes("正在提交数据");
        Map<String,Object> params = new HashMap<>();
        params.put("billId",mView.getCaseid());
        params.put("appContent",appContent);
        params.put("funcId",cFormId);
        params.put("caseStatus","");//暂扣数据状态
        params.put("tbFlag","");//暂扣表名
        params.put("turnType",turnType);
        params.put("turnTable","");//案件表明（自定义表单隐藏字段）
        Disposable disposable = RealNetWorkUtil.postContent()
                .method("api-process/lApp/addOwn")
                .content(params)
                .build().enqueue(String.class, new CallBackImpl<String>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(String objects) {
                        mView.hidePb_mes();
                        mView.showMes(objects);
                        mView.returnApplySuccess();
                    }
                });
        mCompositeDisposable.add(disposable);
    }
    //先行登记和暂扣物品打印
    public void Printwithold(String caseId){
        mView.showPb_mes("正在提交数据");
        Map<String,Object> params = new HashMap<>();
        params.put("id",caseId);
        Disposable disposable = RealNetWorkUtil.get()
                .method("api-case/withhold/printWithHold")
                .params(params)
                .build().enqueue(TempOraryBean.class, new CallBackImpl<TempOraryBean>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(TempOraryBean bean) {
                        mView.hidePb_mes();
                        if (mView.returnType().equals("3")){
                            CasePrintUtil.printWitHold(mActivity,bean);
                        }else if (mView.returnType().equals("4")){
                            CasePrintUtil.printAdvance(mActivity,bean);
                        }

                    }
                });
        mCompositeDisposable.add(disposable);
    }
}
